﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace AllInOne
{
    /// <summary>
    /// SCMOutputWindow.xaml 的交互逻辑
    /// </summary>
    public partial class SCMOutputWindow : Window
    {
        public SCMOutputWindow()
        {
            InitializeComponent();
        }

        public void SetSend(string send)
        {
            this.Dispatcher.Invoke(new Action(delegate ()
            {
                string text = this.txtSend.Text;
                int count = (text.Length - text.Replace("\r\n", "").Length) / 2;
                if (count >= 7)
                {
                    text = text.Substring(text.IndexOf("\r\n") + 2);
                }
                text = text + send + "\r\n";
                this.txtSend.Text = text;
            }));
        }

        public void SetReceive(string receive)
        {
            this.Dispatcher.Invoke(new Action(delegate ()
            {
                string text = this.txtReceive.Text;
                int count = (text.Length - text.Replace("\r\n", "").Length) / 2;
                if (count >= 7)
                {
                    text = text.Substring(text.IndexOf("\r\n") + 2);
                }
                text = text + receive + "\r\n";
                this.txtReceive.Text = text;
            }));
        }
    }
}
